<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../../css/btnplus.css" />
		<style type="text/css">
			html,body{
				background-color: #F7F7F7;
				overflow-y: auto;
				-webkit-overflow-scrolling:touch;
			}
			.search_no{ padding: 40% 0 0;}
			.search_no img{ margin:0 auto; width: 30px;}
			.search_no p{ text-align: center; font-size: 12px; color: #9f9f9f; line-height: 45px; padding-bottom: 5px;}
			.search_no button{ display:block; border: 0; border-radius: 0; width: 120px; height: 36px; margin: 0 auto; color: #fff; background-color: #1c63fa; font-size: 14px;}

			.banner img{ width: 100%;}

			.s_more{ text-align: center; font-size: 12px; color: #999; line-height: 15px; padding-bottom: 20px;}

			.s_type{ height: 45px; background-color: #fff; padding:0 20px;}
			.s_type a{ float: left; width: 33.33%;  text-align: center; font-size: 13px; color: #666; white-space: nowrap;text-overflow: ellipsis; overflow: hidden;}
			.s_type a i{ display:inline-block; vertical-align: top; height: 45px; line-height: 45px; padding-right: 15px; background-position: center right; background-repeat: no-repeat; background-size: 10px auto; background-image: url(../../image/img_44.png);}
			.s_type a:last-child i{ background-image:url(../../image/img_45.png); background-size: 11px auto;}
			.s_type a img{ display:inline-block; vertical-align: top; width: 16px; margin-top: 14px; margin-right: 5px;}
			.s_type a.on{ color:#1c63fa; background-color: transparent;}
			.s_type a.on i{ background-image:url(../../image/img_44a.png);}
			.s_type a:last-child.on i{ background-image:url(../../image/img_45a.png);}

			.s_type.s_fixed{ position: fixed; left: 0; right: 0; top: 45px; z-index: 10;}
			.case_box{ position:fixed; left: 0; right: 0; top: 90px; bottom: 0; background-color: rgba(0,0,0,0.4); overflow-y: auto; z-index: 10;}
			.case_box div{ background-color: #fff;}
			.case_box b{ display: block; font-size: 12px; font-weight: 400; color: #999; padding: 0 10px; line-height: 30px;}
			.case_box .check li,.add_type li{ float:left; width: 33.33%; text-align: center; font-size: 13px; color: #333; line-height: 35px;}
			.case_box .check01 li{ width: 23%;}
			.case_box .check01 li:last-child{ width: 31%;}
			.case_box .check span,.add_type li span{ display:inline-block; vertical-align: top; height: 35px; padding-left: 20px; background: url(../../image/img_24.png) no-repeat left center; background-size: 15px auto;}
			.case_box .check span.on,.add_type li span.on{ background-image:url(../../image/img_25.png);}
			.case_box .check02{ padding: 0 10px;}
			.case_box .check02 li,.add_long li{ float:left; width: 23.5%; margin-right: 2%;margin-bottom: 8px; text-align: center; font-size: 13px; color: #333; line-height: 28px; background-color: #f6f6f6; border-radius: 3px;}
			.case_box .check02 li:nth-child(4n+4),.add_long li:nth-child(4n+4){ margin-right: 0;}
			.case_box .check02 li.on,.add_long li.on{ background-color: #1c63fa; color: #fff;}
			.case_box .btn{ position:relative; height: 40px;}
			.case_box .btn::after{ position:absolute; content: ""; left: 0; top: 0; right: 0; border-top: 1px #d4d4d4 solid; transform: scaleY(0.5);}
			.case_box .btn::before{ position:absolute; content: ""; left: 50%; top: 0; bottom: 0; border-right: 1px #d4d4d4 solid; transform: scaleX(0.5);}
			.case_box .btn button{ display:block; float: left; border: 0; width: 50%; text-align: center; font-size: 14px; color: #333; height: 40px; background-color: transparent; border-radius: 0;}
			.case_box .btn button.on{ color:#1c63fa;}
			
			.order_list{ padding: 10px 15px;}
			.order_list li{ margin-bottom: 10px; background-color: #fff; padding: 0 10px; border-radius: 4px; overflow: hidden;}
			.order_list .title{ position:relative; height: 40px; line-height: 40px; font-size: 13px; color: #999;}
			.order_list .title::after{ position:absolute; content: ""; left: 0; right: 0; bottom: 0; border-bottom: 1px #d4d4d4 solid; transform: scaleY(0.5);}
			.order_list .title p{ float:left;}
			.order_list .title i{ float: right; color: #1c63fa; font-size: 12px;}
			.order_list .con{ padding: 5px 0 10px;}
			.order_list .con h4{ display:block; font-size: 18px; font-weight: 500; color: #333; line-height: 35px;}
			.order_list .con p{ font-size: 14px; color: #5D5D5D; line-height: 18px;white-space: nowrap;text-overflow: ellipsis; overflow: hidden;}
			.order_list .con i{ float: left; border-radius: 2px; margin-right: 12px; line-height: 16px; font-size: 12px; padding: 0 6px;}
			.order_list .con img{ display:inline-block; vertical-align: top; height: 5px; margin: 14px 5px 0;}
			.order_list .con span{ margin-top: 7px; display:block; color: #9F9F9F; font-size: 14px; line-height: 25px; height: 25px; overflow: hidden;}
			.order_list .contact{ position:relative; padding: 10px 0;}
			.order_list .contact::after{ position: absolute; content: ""; left: 0; top: 0; right: 0; border-top: 1px #dbdbdb solid; transform: scaleY(0.5);}
			.order_list .contact .m_cell_hd img{ width: 35px; height: 35px; border-radius: 50%; margin-right: 10px;}
			.order_list .contact b{ display:block; font-size: 12px; color: #333; line-height: 15px;}
			.order_list .contact p{ font-size: 12px; color: #999;}
			.order_list .contact a img{ width: 33px; height: 33px;}
			.s_01{border: 1px #CF4242 solid; color: #CF4242;}
			.s_02{border: 1px #69C8A2 solid; color: #69C8A2;}
			.s_03{border: 1px #3262F1 solid; color: #3262F1;}
			.memo { margin-top:10px; font-size:14px; color:#9F9F9F !important; }
			.text-center { text-align: center !important; }
			.display-none{ display:none; }			
			.sk-three-bounce {
			  margin: 120px auto;
			  width: 80px;
			  text-align: center; }
			  .sk-three-bounce .sk-child {
				width: 13.5px;
				height: 13.5px;
				background-color: #3262F1;
				border-radius: 100%;
				display: inline-block;
				-webkit-animation: sk-three-bounce 1.4s ease-in-out 0s infinite both;
						animation: sk-three-bounce 1.4s ease-in-out 0s infinite both; }
			  .sk-three-bounce .sk-bounce1 {
				-webkit-animation-delay: -0.32s;
						animation-delay: -0.32s; }
			  .sk-three-bounce .sk-bounce2 {
				-webkit-animation-delay: -0.16s;
						animation-delay: -0.16s; }

			@-webkit-keyframes sk-three-bounce {
			  0%, 80%, 100% {
				-webkit-transform: scale(0);
						transform: scale(0); }
			  40% {
				-webkit-transform: scale(1);
						transform: scale(1); } }

			@keyframes sk-three-bounce {
			  0%, 80%, 100% {
				-webkit-transform: scale(0);
						transform: scale(0); }
			  40% {
				-webkit-transform: scale(1);
						transform: scale(1); }
			}
		</style>
	</head>
	<body>
		<div id="result">
		<div style="display:display;width:100%;height:125px;content:'';" id="banner"></div>
		<!--条件start-->
		<div class="s_type" id="navfilter" style="position:relative;top:0;left: 0; right: 0;z-index:10;">
			<a href="javascript:;" tapmode onclick="filter(this);" attr-type="1"><i><img src="../../image/img_42.png" alt="" /><span id="myposition">定位中</span></i></a>
			<a href="javascript:;" tapmode onclick="filter(this);" attr-type="2"><i><img src="../../image/img_41.png" alt="" /><span id="destarea">全国</span></i></a>
			<a href="javascript:;" tapmode onclick="filter(this);" attr-type="3"><i>筛选</i></a>
		</div>
		<!--条件end-->

		<!--列表start-->
		<div class="order_list">
			<ul id="goodslist">

			</ul>
			<script id="goodslist_template" type="text/template">
				{{ for (var i = 0, len = it.length; i < len; i++) { }}
				<li tapmode onclick="openNavWin('#ddd','goodsdetail_win','goodsdetail_frm.html','货源详情',false,false,true,[],{goodsid:{{=it[i].id}},fromfrm:'searchgoods'});">
					<div class="con">
						<h4>{{=it[i].sendaddress}} <img src="../../image/img_21.png" alt="" /> {{=it[i].destaddress}}</h4>
						<p class="clearfix"><i class="s_0{{=it[i].loadingdatestatus}}">{{=it[i].loadingdate}}装车</i>{{=it[i].cartype}}/{{=it[i].carlen}}/{{=it[i].weightv}}/{{=it[i].goodstype}}</p>
						{{? it[i].memo!=''}}
						<p class="clearfix memo">{{=it[i].memo}}</p>
						{{?}}
					</div>
					<div class="contact">
						<div class="m_cell_hd"><img data-echo="{{=it[i].avatar}}" src="../../image/defaultimg.png" onerror="javascript:this.src='../../image/defaultimg.png';" /></div>
						<div class="m_cell_hd m_cell_primary">
							<b>{{=it[i].realname}}</b>
							<p>{{=it[i].createtime}}</p>
						</div>
						<div class="m_cell_ft"><a href="javascript:;" tapmode onclick="checkcall('{{=it[i].mobile}}')"><img src="../../image/img_34.png" alt="" /></a></div>
					</div>
				</li>
				{{ } }}
			</script>
		</div>
		<div class="s_more display-none">没有更多了</div>
		<!--列表end-->
		</div>
		<div class="text-center display-none" style="padding: 60px 0 !important;" id="divnodata">
			<div class="text-center"><img src="../../image/nofound.png" style="margin:0 auto;width:41px;height:auto;"></div>
			<p class="text-center" style="font-size:12px;color:#9f9f9f;margin-top:15px;">暂无货源信息</p>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/app.js"></script>
	<script type="text/javascript" src="../../script/permission.js"></script>
	<script type="text/javascript" src="../../script/doT.js"></script>
	<script type="text/javascript" src="../../script/echo.js"></script>
	<script type="text/javascript">
		var page = 1;
		var aMap;
		var UIScrollPicture;
		var thumbarr = [];
		var cacheimgs = [];		
		var params = {
			where: {
				sendprovinceId: '',
				sendcityId: '',
				sendareaId: '',
				destprovinceId: '',
				destcityId: '',
				destareaId: '',
				sendcity: '',
				destarea: '',
				transporttype: 0,
				loadingtime: 0,
				cartype: [],
				carlen: [],
				keyword: '',
				keywordtype: ''
			},
			page: 1
		};
		var linesid;
		var sendprovinceId = '', sendcityId = '', sendareaId = '';
		var destprovinceId = '', destcityId = '', destareaId = '';
		var sendcity = '', destarea = ''; //当前定位城市
		var transporttype = 0; //用车类型
		var cartype = [];
		var carlen = []; //车长
		var loadingtime = 0; //0表示不限时间
		var lon,lat;
		var bannerClick = 0; //banner加载完才可以点击
		function echoInit() {
			echo.init({
					offset : 0,
					throttle : 0 //设置图片延迟加载的时间
			});
		}
		var UILoading;
		apiready = function() {
			api.parseTapmode();
			UILoading = api.require('UILoading');
			linesid = api.pageParam.linesid;
			var filtersetjson = {
				sendprovinceId: '',
				sendcityId: '',
				sendareaId: '',
				destprovinceId: '',
				destcityId: '',
				destareaId: '',
				sendcity: '',
				destarea: '',
				transporttype: 0,
				loadingtime: 0,
				cartype: [],
				carlen: [],
				keyword: '',
				keywordtype: ''
			};
			api.setPrefs({
				key: 'filterset',
				value: filtersetjson
			}, function(ret, err) {
			});
			api.addEventListener({
				name : 'reloadpage'
			}, function(ret, err) {
				page = 1;
				getJsonFromAPI();				
			});
			api.addEventListener({
				name : 'refreshgoodlist'
			}, function(ret, err) {
				page = 1;
				getJsonFromAPI();				
			});
			api.addEventListener({
                name: 'navitembtn'
            }, function(ret, err) {
                if (ret.type == 'left') {
					api.closeWin({
					});
                }
				else if (ret.type == 'right') {
					opWin('search_win','search_win.html',true,{},false);
					//openNavWin('#ddd','search_win','search_frm.html','发布货源',false,false,true,[],{});
                }
            });
			UIScrollPicture = api.require('UIScrollPicture');
			banner();

			
			params = {
				where: {
					sendprovinceId: sendprovinceId,
					sendcityId: sendcityId,
					sendareaId: sendareaId,
					destprovinceId: destprovinceId,
					destcityId: destcityId,
					destareaId: destareaId,
					sendcity: sendcity,
					destarea: destarea,
					transporttype: transporttype,
					loadingtime: loadingtime,
					cartype: cartype,
					carlen: carlen,
					keyword: '',
					keywordtype: ''
				},
				page: 1
			};
			showloading();
			getJsonFromAPIBylineid();
			api.addEventListener({
				name:"scrolltobottom"
			},function(ret,err){
				getJsonFromAPI();
			});
			menuFixed('navfilter'); //nav固定顶部
			
		}
		function menuFixed(id) {
			var obj = document.getElementById(id);
			var _getHeight = obj.offsetTop;

			window.onscroll = function () {
				changePos(id, _getHeight);
			}
		}

		function changePos(id, height) {
			var obj = document.getElementById(id);
			var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
			//console.log(scrollTop);
			if (scrollTop < 125) {
				//obj.style.top = scrollTop;
				$api.css($api.byId('goodslist'),'margin-top:0px');
				obj.style.position = 'relative';
			} else {
				$api.css($api.byId('goodslist'),'margin-top:45px');
				//obj.style.top = 0;
				obj.style.position = 'fixed';
			}
		}
		function refreshthumb(imgarr)
		{
			//刷新banner图片集
			UIScrollPicture.reloadData({
				data: {
					paths: imgarr
				}
			});
			bannerClick = 1;
		}
		function restoreLi() {
			//恢复为未选择状态
			var liList = document.getElementById("navfilter").children;
			for (var i = 0; i < liList.length; i++) {
				$api.removeCls(liList[i], 'on')
			}
		}
		function filter(obj) {
			var filtertype = $api.attr(obj,'attr-type');
			$api.toggleCls(obj, 'on');
			if($api.hasCls(obj, 'on'))
			{
				//发送自定义事件，用于改变筛选类型
				api.sendEvent({
					name: 'changeFiltertype',
					extra: {
						filtertype: filtertype
					}
				});
				api.openFrame({
					name: 'filter_frm',
					url: 'filter_frm.html',
					bounces: false,
					rect: {
						x: 0,
						y: api.safeArea.top + 45,
						w: 'auto',
						h: 'auto'
					},
					bgColor: 'rgba(0,0,0,0.6)',
					pageParam: {
						filtertype: filtertype,
						sendarea: $api.text($api.byId('myposition')),
						destarea: $api.text($api.byId('destarea')),
						fromfrm: 'searchlinegoods_win'
					}
				});
				
				
			}
			else
			{
				//api.closeFrame({
					//name: 'filter_frm'
				//});
				api.setFrameAttr({
					name: 'filter_frm',
					hidden: true
				});
			}
		}
		function banner() {
			api.getPrefs({
				key: 'cacheimgs'
			}, function(ret, err) {
				if (ret && ret.value)
				{
					cacheimgs = JSON.parse(ret.value);
					//alert(JSON.stringify(cacheimgs));
				}
				else
				{
					cacheimgs = ['widget://image/banner.jpg'];
				}
				UIScrollPicture.open({
					rect: {
						x: 0,
						y: 0,
						w: api.winWidth,
						h: 125
					},
					data: {
						paths: cacheimgs
					},
					styles: {
						caption : {
							height : 35,
							color : '#E0FFFF',
							size : 13,
							bgColor : '#696969',
							position : 'overlay'
						},
						indicator : {
							align : 'center',
							color : 'rgba(255, 255, 255, 0.5)',
							activeColor : '#fff'
						}
					},
					//placeholderImg: 'widget://image/banner.jpg',
					contentMode: 'scaleToFill',
					interval: 4,
					fixedOn: api.frameName,
					loop: true,
					fixed: false
				}, function(ret, err) {
					if (ret) {
						if('click' == ret.eventType && bannerClick == 1){
							if(thumbarr[ret.index].bannertype == 1)
							{
								openurl(thumbarr[ret.index].url,thumbarr[ret.index].title);
							}
							else
							{
								openNavWin('#ddd','bannerdetail_win','bannerdetail_frm.html',thumbarr[ret.index].title,false,false,true,[],{bannerid:thumbarr[ret.index].id});
							}
						}
						//alert(JSON.stringify(ret));
					} else {
						//alert(JSON.stringify(err));
					}
				});
			});
		}
		function bannerold() {
			//UIScrollPicture显示banner
			cacheimgs = $api.getStorage('cacheimgs');
			if(typeof(cacheimgs)=="undefined"){
				cacheimgs = ['widget://image/banner.jpg'];
			}
			UIScrollPicture.open({
				rect: {
					x: 0,
					y: 0,
					w: api.winWidth,
					h: 125
				},
				data: {
					paths: cacheimgs
				},
				styles: {
					caption : {
						height : 35,
						color : '#E0FFFF',
						size : 13,
						bgColor : '#696969',
						position : 'overlay'
					},
					indicator : {
						align : 'center',
						color : 'rgba(255, 255, 255, 0.5)',
						activeColor : '#fff'
					}
				},
				//placeholderImg: 'widget://image/banner.jpg',
				contentMode: 'scaleToFill',
				interval: 4,
				fixedOn: api.frameName,
				loop: true,
				fixed: false
			}, function(ret, err) {
				if (ret) {
					if('click' == ret.eventType && bannerClick == 1){
						if(thumbarr[ret.index].bannertype == 1)
						{
							openurl(thumbarr[ret.index].url,thumbarr[ret.index].title);
						}
						else
						{
							openNavWin('#ddd','bannerdetail_win','bannerdetail_frm.html',thumbarr[ret.index].title,false,false,true,[],{bannerid:thumbarr[ret.index].id});
						}
					}
					//alert(JSON.stringify(ret));
				} else {
					//alert(JSON.stringify(err));
				}
			});

		}
		function openurl(url,title) {
			opWin('openurl_win','../my/openurl_win.html',true,{
				title: title,
				url: url
			},false);
		}
		function checkcall(tel) {
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret.value) {
					var userinfo = JSON.parse(ret.value);
					
					if(userinfo.status!=1){
						tipbox(userinfo.status);
						return;
					}
					if(userinfo.mobile == tel) {
						toast('不能呼叫自己');
						return;
					}
					call(tel);
				}
			});
			event.stopPropagation();
		}
		function call(tel) {
			var pername = 'phone';
			var perdesc = '拨打电话';
			if (api.systemType == "android") {
				if(!confirmPer(pername,perdesc,'')){
					return;
				}
			}
			if(tel != '')
			{
				if(api.systemType == 'ios'){
					api.call({
						type: 'tel_prompt',
						number: tel
					});
				}else{
					api.confirm({
						title: '确认拨打电话吗?',
						msg: tel,
						buttons: ['取消', '呼叫']
					}, function(ret, err) {
						var index = ret.buttonIndex;
						if(index == 2)
						{
							api.call({
								type: 'tel',
								number: tel
							});
						}
					});
				}
			}
			
		}
		function getFilterJsonFromAPI(jsonData) {
			//console.log(jsonData);
			//筛选获取数据
			api.closeFrame({
				name: 'filter_frm'
			});
			restoreLi();
			page = 1;
			params = $api.strToJson(jsonData);
			if(params.where.sendcity != '')
			{
				$api.text($api.byId('myposition'),params.where.sendcity);
			}
			if(params.where.destarea != '')
			{
				$api.text($api.byId('destarea'),params.where.destarea);
			}
			//alert(JSON.stringify(params));
			getJsonFromAPI();
		}
		function getJsonFromAPIBylineid() {
			//从接口获取查询数据
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret.value) {
					var userinfo = JSON.parse(ret.value);
					api.ajax({
						url: ApiUrl + '/v1/searchlinegoods/'+linesid,
						method: 'get',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						}
					}, function(ret, err) {
						hideloading();
						$api.removeCls($api.byId('result'), 'display-none');
						if (ret) {
							if(page==1)
							{
								thumbarr = ret.banners;
								var imgthumbarr = [];
								for(var item in thumbarr){
									imgthumbarr.push(thumbarr[item].thumb);
								}
								api.getPrefs({
									key: 'cacheimgs'
								}, function(ret, err) {
									if (ret && ret.value)
									{
										//alert(JSON.stringify(ret));
										//cacheimgs = JSON.parse(ret.value);
										cacheimgs = ret.value;
										if(cacheimgs!=imgthumbarr){
											//$api.setStorage('cacheimgs', imgthumbarr);
											api.setPrefs({
												key: 'cacheimgs',
												value: imgthumbarr
											}, function(ret, err) {
												if(ret)
												{
													
												}
											});
											refreshthumb(imgthumbarr);
										}
									}
									else
									{
										api.setPrefs({
											key: 'cacheimgs',
											value: imgthumbarr
										}, function(ret, err) {
											if(ret)
											{
												
											}
										});
										refreshthumb(imgthumbarr);
									}
								});
								$api.text($api.byId('myposition'),ret.sendarea);
								$api.text($api.byId('destarea'),ret.destarea);
								filtersetjson = {
									sendprovinceId: ret.filterarr.sendprovinceId,
									sendcityId: ret.filterarr.sendcityId,
									sendareaId: ret.filterarr.sendareaId,
									destprovinceId: ret.filterarr.destprovinceId,
									destcityId: ret.filterarr.destcityId,
									destareaId: ret.filterarr.destareaId,
									sendcity: '',
									destarea: '',
									transporttype: ret.filterarr.transporttype,
									loadingtime: ret.filterarr.loadingtime,
									cartype: ret.filterarr.cartype,
									carlen: ret.filterarr.carlen,
									keyword: '',
									keywordtype: ''
								};
								api.setPrefs({
									key: 'filterset',
									value: filtersetjson
								}, function(ret, err) {
								});
								
								//thumbarr = [];
								//thumburl = [];
								//thumbtitle = [];
								//for(var item in ret.banners){
									//thumbarr.push(ret.banners[item].thumb);
									//thumburl.push(ret.banners[item].url);
									//thumbtitle.push(ret.banners[item].title);
								//}
								//cacheimgs = $api.getStorage('cacheimgs');
								//if(cacheimgs!=thumbarr){
									//$api.setStorage('cacheimgs', thumbarr);
									//refreshthumb(thumbarr);
								//}
							}
							if(ret.list.length > 0)
							{
								$api.addCls($api.byId('divnodata'),'display-none');
								var isAppend = true;
								if(page==1)
								{
									isAppend = false;
								}
								page++;
								var goodslist = ret.list;
								UpdateList('goodslist','goodslist_template',goodslist,isAppend);
							}
							else
							{
								if(page==1)
								{
									UpdateList('goodslist','goodslist_template',ret.list,false);
									$api.removeCls($api.byId('divnodata'),'display-none');
								}
							}
							
						} else {
							if(err.statusCode==402)
							{
								Relogin();
							}
							else
							{
								console.log(JSON.stringify(err));
								toast('网络异常');
							}
						}
					});
				}
			});
		}
		function getJsonFromAPI() {
			//从接口获取查询数据
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret.value) {
					var userinfo = JSON.parse(ret.value);
					console.log(ApiUrl + '/v1/searchgoods/'+page+'/'+ $api.jsonToStr(params));
					api.ajax({
						url: ApiUrl + '/v1/searchgoods/'+page+'/'+ $api.jsonToStr(params),
						method: 'get',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						}
					}, function(ret, err) {
						hideloading();
						$api.removeCls($api.byId('result'), 'display-none');
						if (ret) {
							if(page==1)
							{
								thumbarr = ret.banners;
								var imgthumbarr = [];
								for(var item in thumbarr){
									imgthumbarr.push(thumbarr[item].thumb);
								}
								api.getPrefs({
									key: 'cacheimgs'
								}, function(ret, err) {
									if (ret && ret.value)
									{
										//alert(JSON.stringify(ret));
										//cacheimgs = JSON.parse(ret.value);
										cacheimgs = ret.value;
										if(cacheimgs!=imgthumbarr){
											//$api.setStorage('cacheimgs', imgthumbarr);
											api.setPrefs({
												key: 'cacheimgs',
												value: imgthumbarr
											}, function(ret, err) {
												if(ret)
												{
													
												}
											});
											refreshthumb(imgthumbarr);
										}
									}
									else
									{
										api.setPrefs({
											key: 'cacheimgs',
											value: imgthumbarr
										}, function(ret, err) {
											if(ret)
											{
												
											}
										});
										refreshthumb(imgthumbarr);
									}
								});
								
							}
							if(ret.list.length > 0)
							{
								$api.addCls($api.byId('divnodata'),'display-none');
								var isAppend = true;
								if(page==1)
								{
									isAppend = false;
								}
								page++;
								var goodslist = ret.list;
								UpdateList('goodslist','goodslist_template',goodslist,isAppend);
							}
							else
							{
								if(page==1)
								{
									UpdateList('goodslist','goodslist_template',ret.list,false);
									$api.removeCls($api.byId('divnodata'),'display-none');
								}
							}
							
						} else {
							if(err.statusCode==402)
							{
								Relogin();
							}
							else
							{
								console.log(JSON.stringify(err));
								toast('网络异常');
							}
						}
					});
				}
			});
		}
		//渲染数据
		function UpdateList(domId,templateId,jsondata,isAppend) {
			//console.log(JSON.stringify(jsondata));
			var act_content = $api.byId(domId);
			var tempFn = doT.template($api.byId(templateId).innerHTML);
			var resultText = tempFn(jsondata);
			//alert(isAppend);
			//console.log(resultText);
			if(isAppend)
			{
				$api.append(act_content, resultText);
			}
			else
			{
				$api.html(act_content, resultText);
			}
			api.parseTapmode();
			setTimeout(function() {
				echoInit();
			}, 300);
		}
	</script>
</html>